﻿<!DOCTYPE html>
<html lang="en" window-frame="solid" window-icon="./view/icon/server-favicon.ico"></html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="./view/css/index.css">
</head>
<body role="window-caption">
     <div id="box">
        <div class="title_box skinbg">
                <div class="head">
                    <div class="title fl" >
                            <a href="./view/index.html" class="backicon topiconBg"></a>
                    </div>
                    <div class="setting fr">
                        <ul>
                            <li class="setbtn">
                                <span class="setbtnicon topiconBg"></span>
                                <ul class="setmess">
                                    <li>
                                        <button id="passwordmode" class="passwordicon">更改密码</button>
                                    </li>
                                    <li id="upsetmysql">
                                        <button class="upsetmysql">更改数据库配置</button>
                                    </li>   
                                    <li>
                                        <button id="logoutmode" class="logouticon">切换账户</button>
                                    </li>
                                    <li>
                                        <button id="exitmode" class="exiticon">退出</button>
                                    </li>
                                    <li>
                                        <button id="aboutmode" class="abouticon">关于</button>
                                    </li>
                                </ul>
                            </li>
                            <li>
                                <button id="minimized" class="minimizedicon topiconBg"></button>
                            </li>
                            <li>
                                <button id="closewin" class="closewinicon topiconBg"></button>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="detail_title">
                    <div class="detailicon taskicon fl"></div>
                    <div class="detailword fl">
                        <h3 class="detailh3">相关任务</h3>
                        <p class="detailp">恢复简单，避免数据损坏</p>
                    </div>
                    <div class="handlebutton">

                    </div>
                </div>
        </div>
        <div class="showmess">
            <div class="nonebox">
                <img src="./view/img/NOneimg.png" alt="">
                <p>暂无数据</p>
            </div>
            <div class="detailsbox disp">
              <div class="showtable">
                  <table border="0" cellpadding="0" cellspacing="0">
                        <thead>
                            <tr>
                                <th>任务名称</th>
                                <th>数据库名</th>
                                <th>状态</th>
                                <th>开始日期</th>
                                <th>周期</th>
                                <th>创建日期</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="tby" class="respfile">

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- 提示 -->
        <div id="messtip">
            <i id="messtipicon" class="successicon"></i>
            <!-- 成功 successicon 失败 defeaticon -->
            <span class="messtipword">您的操作 <span class="reminderhandle"></span> 了呀！<span class="errorhandle"></span> </span>
        </div>
        <!-- 提示 -->
    </div>
    <script type="text/tiscript" src="./view/tiscript/index.tis"></script>
        <script type="text/tiscript" src="./view/tiscript/public.tis"></script>
        <script type="text/tiscript">
            self.ready = function() {
                notdisplay()
                gettask()
            }
            var notdisplay = function(){
                var isconfig = view.sqlisconfig()
                if (!isconfig){
                    $(.handlebutton).html = `<button type="setmysql" class="layui-btn addtaskbtn">数据库配置</button>`
                    $(#upsetmysql).style["display"] = "none"; 
                }else{
                    $(.handlebutton).html = `<button type="addtask"  class="layui-btn addtaskbtn">添加任务</button>`
                    $(#upsetmysql).style["display"] = "black"; 
                }
            }
            // 获取 任务列表
           var gettask = function (){
                var tlist = view.GetTasklist();
            
                var tb = "" ,repeatcount = "",status = "";
                if(typeof tlist != #string && typeof tlist == #array ){
                    $(.nonebox).style["display"] = "none"
                    $(.disp).style["display"] = "block"
                  for (var (key,v) in tlist){
                   
                      if(!v.status){ 
                        status = "执行中"
                      }else if (v.status == 1){
                        status = "执行中"
                      }else if (v.status == 2){
                      status = "执行失败"
                    }else if (v.status == 3){
                        status = "任务完成"
                  }
    
                      tb += `
                             <tr>
                                    <td> `+v.name+`</td>
                                    <td> `+v.database+`</td>
                                    <td> `+status+` </td>
                                    <td>  `+v.starttime+` </td>
                                    <td> `+v.interval+`</td>
                                    <td>  `+v.intime+`</td>
                                    <td class="button" style="width:100px;">
                                        <button class="layui-btn" type="delete" deleteuuid="`+v.uuid+`" deletename="`+v.name+`">删除</button>
                                    </td>
                              </tr>
                           `  ;                  
                    }
                    $(#tby).html = tb; 
                  }else{
                    $(.nonebox).style["display"] = "block"
                    $(.disp).style["display"] = "none"
                  }
               }
               
               // 更改  数据库配置
               $(#upsetmysql).on("click", function() {
                       view.dialog({
                           //加载到对话框中的URL，可加载本地文件
                           url: "./view/upsetmysql.html",
                           //对话框的x，y坐标
                           x: 542.5,
                           y: 282.5,
                           //窗口的宽度，高度
                           width: 647,
                           height: 447,
                           //是否是客户区，如果为真，那么x，y，width，height作为客户区坐标，而不是窗口
                           client: false,
                           //对话框参数
                           parameters: {"newin":view,"fun":gettask,"success":success,"error":error},
                           //对话框标题
                           caption: "新对话框",
                           //相对于屏幕窗口对齐
                           alignment: 1,
                       });
                   });

                event click $(button) (evt, element) {  
                    if(this.attributes["type"] == "addtask"){
                    // 添加任务
                        view.dialog({
                            //加载到对话框中的URL，可加载本地文件
                            url: "./view/addtaskmode.html",
                            //对话框的x，y坐标
                            x: 542.5,
                            y: 282.5,
                            //窗口的宽度，高度
                            width: 647,
                            height: 447,
                            //是否是客户区，如果为真，那么x，y，width，height作为客户区坐标，而不是窗口
                            client: false,
                            //对话框参数
                            parameters: {"newin":view,"fun":gettask,"success":success,"error":error},
                            //对话框标题
                            caption: "新对话框",
                            //相对于屏幕窗口对齐
                            alignment: 1,
                        });
                    }else if(this.attributes["type"] == "setmysql"){
                        // 设置 数据库配置
                        view.dialog({
                            //加载到对话框中的URL，可加载本地文件
                            url: "./view/setmysql.html",
                            //对话框的x，y坐标
                            x: 542.5,
                            y: 282.5,
                            //窗口的宽度，高度
                            width: 647,
                            height: 447,
                            //是否是客户区，如果为真，那么x，y，width，height作为客户区坐标，而不是窗口
                            client: false,
                            //对话框参数
                            parameters: {"newin":view,"fun":notdisplay,"success":success,"error":error},
                            //对话框标题
                            caption: "新对话框",
                            //相对于屏幕窗口对齐
                            alignment: 1,
                        });
                    }else if(this.attributes["type"] == "delete"){
                        var deleteuuid = this.attributes["deleteuuid"];
                        var deletename = this.attributes["deletename"];
                       
                        var argument = {
                            "newin":view,
                            "type":"delete",
                            "title":"删除任务",
                            "text":"删除任务名为"+deletename,
                            "buttons":[{id:"close",text:"取消"},{id:"yes",text:"确认"}],
                            deleteuuid:deleteuuid,
                            "fun":gettask,
                            "success":success,
                            "error":error
                        }

                        view.dialog({
                            //加载到对话框中的URL，可加载本地文件
                            url: "./view/popup.html",
                            //对话框的x，y坐标
                            x: 0,
                            y: 0,
                            //窗口的宽度，高度
                            width: 270,
                            height: 160,
                            //是否是客户区，如果为真，那么x，y，width，height作为客户区坐标，而不是窗口
                            client: false,
                            //对话框 参数
                            parameters: argument,
                            //对话框标题
                            caption: "新对话框",
                            //相对于屏幕窗口对齐
                            alignment: 1,
                        });
                    }
                }
       </script>
    </body>
</html>